this._appSearchHeader.countText.text = this._appSearchResultArea.display.getMatchedItemsCount() + "";
this._docSearchHeader.countText.text = this._docSearchResultArea.display.getMatchedItemsCount() + "";
+ if (this._appSearchResultArea.display.hasItems() && !this._getOnlyDocSearchShown()) {
+ this._appSearchResultArea.display.selectFirstItem();
+ this._docSearchResultArea.display.unsetSelected();
+ } else if (this._docSearchResultArea.display.hasItems() && !this._getOnlyAppSearchShown()) {
+ this._docSearchResultArea.display.selectFirstItem();
+ this._appSearchResultArea.display.unsetSelected();
+ }
+
return false;
}));
}));
// too, but there doesn't seem to be any flickering if we first select
// something in one display, but then unset the selection, and move
// it to the other display, so it's ok to do that.
- if (this._docSearchResultArea.display.hasSelected())
- this._docSearchResultArea.display.selectUp();
- else if (this._appSearchResultArea.display.hasItems())
- this._appSearchResultArea.display.selectUp();
- else
- this._docSearchResultArea.display.selectUp();
+ if (this._appSearchResultArea.display.hasSelected()) {
+ if (!this._appSearchResultArea.display.selectUp() && this._docSearchResultArea.display.hasItems() && !this._getOnlyAppSearchShown()) {
+ this._docSearchResultArea.display.selectLastItem();
+ this._appSearchResultArea.display.unsetSelected();
+ }
+ } else if (this._docSearchResultArea.display.hasSelected()) {
+ if (!this._docSearchResultArea.display.selectUp() && this._appSearchResultArea.display.hasItems() && !this._getOnlyDocSearchShown()) {
+ this._appSearchResultArea.display.selectLastItem();
+ this._docSearchResultArea.display.unsetSelected();
+ }
+ }
return true;
} else if (symbol == Clutter.Down) {
if (!this._searchActive)
return true;
- if (this._docSearchResultArea.display.hasSelected())
- this._docSearchResultArea.display.selectDown();
- else if (this._appSearchResultArea.display.hasItems())
- this._appSearchResultArea.display.selectDown();
- else
- this._docSearchResultArea.display.selectDown();
+ if (this._appSearchResultArea.display.hasSelected()) {
+ if (!this._appSearchResultArea.display.selectDown() && this._docSearchResultArea.display.hasItems() && !this._getOnlyAppSearchShown()) {
+ this._docSearchResultArea.display.selectFirstItem();
+ this._appSearchResultArea.display.unsetSelected();
+ }
+ } else if (this._docSearchResultArea.display.hasSelected()) {
+ if (!this._docSearchResultArea.display.selectDown() && this._appSearchResultArea.display.hasItems() && !this._getOnlyDocSearchShown()) {
+ this._appSearchResultArea.display.selectFirstItem();
+ this._docSearchResultArea.display.unsetSelected();
+ }
+ }
return true;
}
return false;
} else {
this._appSearchHeader.actor.hide();
this._appSearchResultArea.actor.hide();
+ this._appSearchResultArea.display.unsetSelected();
+ this._docSearchResultArea.display.selectFirstItem();
this._docSearchResultArea.controlBox.show();
this._docSearchHeader.setShowTooltip(false);
}
} else {
this._docSearchHeader.actor.hide();
this._docSearchResultArea.actor.hide();
+ this._docSearchResultArea.display.unsetSelected();
+ this._appSearchResultArea.display.selectFirstItem();
this._appSearchResultArea.controlBox.show();
this._appSearchHeader.setShowTooltip(false);
}
// Returns true if the display has any displayed items.
hasItems: function() {
- return this._list.displayedCount > 0;
+ // TODO: figure out why this._list.displayedCount is returning a
+ // positive number when this._mathedItems.length is 0
+ // This can be triggered if a search string is entered for which there are no matches.
+ // log("this._mathedItems.length: " + this._matchedItems.length + " this._list.displayedCount " + this._list.displayedCount);
+ return this._matchedItems.length > 0;
},
getMatchedItemsCount: function() {
// Displays the page specified by the pageNumber argument.
displayPage: function(pageNumber) {
+ // Cleanup from the previous selection, but don't unset this._selectedIndex
+ if (this.hasSelected()) {
+ this._findDisplayedByIndex(this._selectedIndex).markSelected(false);
+ }
this._list.page = pageNumber;
},
*/
_updateDisplayControl: function(resetDisplayControl) {
if (resetDisplayControl) {
- this._selectedIndex = -1;
this.displayControl.remove_all();
let nPages = this._list.n_pages;
let pageNumber = this._list.page;
}
}
}
+ if (this.hasSelected()) {
+ this.selectFirstItem();
+ }
},
// Returns a display item based on its index in the ordering of the
// Selects (e.g. highlights) a display item at the provided index,
// updates this.selectedItemDetails actor, and emits 'selected' signal.
_selectIndex: function(index) {
- if (index >= this._list.displayedCount)
- return
-
- // If the item is already selected, all we do is toggling the details pane.
- if (this._selectedIndex == index && index >= 0) {
- this.emit('details', index);
- return;
- }
-
// Cleanup from the previous item
- if (this._selectedIndex >= 0) {
+ if (this.hasSelected()) {
this._findDisplayedByIndex(this._selectedIndex).markSelected(false);
}